import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:get/get.dart';
import 'package:gourmet/event/index.dart';
import 'package:gourmet/extensions/ex_widget.dart';
import 'package:gourmet/route/index.dart';
import 'package:gourmet/utils/colors.dart';
import 'package:gourmet/utils/radian.dart';
import 'package:gourmet/utils/styles.dart';
import 'package:gourmet/utils/svg.dart';

class CancelSuccessController extends GetxController {
  final double navHeight = 44 + Get.mediaQuery.padding.top;
  final double navTop = 44.0;
}

class CancelSuccessPage extends GetView<CancelSuccessController> {
  const CancelSuccessPage({super.key});

  @override
  Widget build(BuildContext context) {
    return MediaQuery.removeViewPadding(
      context: context,
      removeBottom: true,
      removeLeft: true,
      removeRight: true,
      removeTop: true,
      child: Scaffold(
        backgroundColor: Colors.white,
        appBar: PreferredSize(
          preferredSize: Size.fromHeight(controller.navHeight),
          child: AnnotatedRegion<SystemUiOverlayStyle>(
            value: SystemUiOverlayStyle.dark,
            child: Container(
              color: Colors.white,
              height: controller.navHeight,
              padding: Get.mediaQuery.padding,
            ),
          ),
        ),
        body: SingleChildScrollView(
          child: Column(
            children: [
              Container(
                margin: const EdgeInsets.only(top: 20, bottom: 20),
                alignment: Alignment.center,
                child: SvgUtils.assetName('u8496', width: 90, height: 90),
              ),
              Container(
                alignment: Alignment.center,
                margin: const EdgeInsets.only(bottom: 30),
                child: Text(
                  '帐号注销成功',
                  style: StylesUtils.customTextStyle(
                    fontSize: StylesUtils.fontSize20,
                    color: ColorsUtils.colorFf6e,
                  ),
                ),
              ),
              Container(
                alignment: Alignment.center,
                margin: const EdgeInsets.only(bottom: 50),
                child: Text(
                  '感谢您对小默外卖的支持',
                  style: StylesUtils.customTextStyle(
                    color: ColorsUtils.color9999,
                  ),
                ),
              ),
              Center(
                child: Container(
                  constraints:
                      const BoxConstraints.expand(width: 315, height: 45),
                  alignment: Alignment.center,
                  decoration: BoxDecoration(
                    borderRadius: BorderRadius.circular(23),
                    gradient: LinearGradient(
                      colors: [
                        ColorsUtils.rgba(255, 153, 0, 1),
                        ColorsUtils.rgba(255, 153, 0, 1),
                        ColorsUtils.rgba(254, 70, 1, 1),
                        ColorsUtils.rgba(254, 70, 1, 1)
                      ],
                      stops: const [
                        0,
                        0,
                        1,
                        1,
                      ],
                      begin: Alignment.topLeft,
                      end: Alignment.bottomRight,
                      transform: GradientRotation(
                        RadianUtils.angleToRadian(90),
                      ),
                    ),
                  ),
                  child: Text(
                    '完成',
                    style: StylesUtils.customTextStyle(
                      fontSize: StylesUtils.fontSize16,
                    ),
                  ),
                ).onTap(() {
                  // 返回首页
                  eventBus.fire(HomeEvent(0));
                  Get.offNamedUntil(Routes.home,
                      (route) => route.settings.name == Routes.home);
                }),
              )
            ],
          ),
        ),
      ),
    );
  }
}
